package May;

import java.util.Scanner;

public class DAY0528 {
    //汽水瓶
    public static void main1(String[] args) {
        //多个输入处理：
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()){
            int nums = scanner.nextInt();
            if (nums!=0){
                System.out.println(Soda(nums));
            }
        }
    }
    public static int Soda(int n){
        //判断方法
        int count = 0;
        while (n>2){
            count = count + n/3;
            n = n/3 + n%3;
        }
        //两个瓶子可以向老板借一个
        if (n == 2){
            count = count +1;
        }
        return count;
    }


    //两个字符串的最长公共子串
    public static void main(String[] args) {
        //接收
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()){
            String a = scanner.nextLine();
            String b = scanner.nextLine();
            //调整前后顺序
            if (a.length() <= b.length()){
                common_substring(a,b);
            }else {
                common_substring(b,a);
            }
        }
    }
//查找两个字符串a,b中的最长公共子串
    private static void common_substring(String a, String b) {
        String result = "";
        for (int i = 1; i < a.length(); i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = i - 1; j < a.length(); j++) {
                if (b.contains(sb.append(a.charAt(j)))) {
                    if (sb.length() > result.length()) {
                        result = sb.toString();
                    }
                }
            }
        }
        System.out.println(result);
    }


}
